<template>
  <van-tabs v-model="active" @change="onChange" swipeable sticky animated>
    <van-tab title="待审核" :badge="counts.pending">
      <slot name="tab0"></slot>
    </van-tab>
    <van-tab title="在售" :badge="counts.pass">
      <slot name="tab1"></slot>
    </van-tab>
    <van-tab title="已售出" :badge="counts.done">
      <slot name="tab2"></slot>
    </van-tab>
  </van-tabs>
</template>

<script>
export default {
  props: ['value'],
  data() {
    return {
      active: this.value,
      counts: {
        took: '',
        frozen: '',
        done: '',
      },
    }
  },
  created() {
    this.getStatis()
  },
  methods: {
    onChange(val) {
      this.$emit('input', val)
      this.getStatis()
    },
    getStatis() {
      this.axios.get('/my/sells/statis').then(res => {
        this.counts = {
          took: '',
          frozen: '',
          done: '',
          ...res.data.data,
        }
      })
    },
  },
}
</script>

<style>
</style>